const Store = require('./store.js')
const permission=require('../config/permission.js')


module.exports= new Store({
  openPart: true,
  state:{
    address: {},
    addressEditor: {},
  },
  methods:{
   
  },
  pageLisener:{
    onLoad(options){
      wx.hideShareMenu()
      console.log(this.route,options)
      if (permission.includes(this.route)){
        //判断是否登录
        try {
          const openId = wx.getStorageSync('userState').openId;
          //没有授权
          if (!openId) {
            let uri = this.route + "#" + JSON.stringify(options)
            wx.redirectTo({
              url: `/pages/auth/index?hashUrl=/${uri}`
            })
          }
          this.setData({ openId: openId })
        } catch (e) {
          console.log('获取不到openid')
        }
      }
    },
    onUnload(){
      
    }

  }
})